package com.ruoyi.project.simple.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.simple.domain.SplSimpleType;
import com.ruoyi.project.simple.service.ISplSimpleTypeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 样品种类Controller
 * 
 * @author ruoyi
 * @date 2020-01-09
 */
@Api("样品种类")
@RestController
@RequestMapping("/simple/simpleType")
public class SplSimpleTypeController extends BaseController
{
    @Autowired
    private ISplSimpleTypeService splSimpleTypeService;

    /**
     * 查询样品种类列表
     */
    @ApiOperation("查询样品种类列表")
    @GetMapping("/list")
    public TableDataInfo list(SplSimpleType splSimpleType)
    {
        startPage();
        List<SplSimpleType> list = splSimpleTypeService.selectSplSimpleTypeList(splSimpleType);
        return getDataTable(list);
    }

    /**
     * 导出样品种类列表
     */
    @PreAuthorize("@ss.hasPermi('simple:simpleType:export')")
    @Log(title = "样品种类", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SplSimpleType splSimpleType)
    {
        List<SplSimpleType> list = splSimpleTypeService.selectSplSimpleTypeList(splSimpleType);
        ExcelUtil<SplSimpleType> util = new ExcelUtil<SplSimpleType>(SplSimpleType.class);
        return util.exportExcel(list, "simpleType");
    }

    /**
     * 获取样品种类详细信息
     */
    @PreAuthorize("@ss.hasPermi('simple:simpleType:query')")
    @GetMapping(value = "/{simpleTypeId}")
    public AjaxResult getInfo(@PathVariable("simpleTypeId") Integer simpleTypeId)
    {
        return AjaxResult.success(splSimpleTypeService.selectSplSimpleTypeById(simpleTypeId));
    }

    /**
     * 新增样品种类
     */
    @PreAuthorize("@ss.hasPermi('simple:simpleType:add')")
    @Log(title = "样品种类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SplSimpleType splSimpleType)
    {
        return toAjax(splSimpleTypeService.insertSplSimpleType(splSimpleType));
    }

    /**
     * 修改样品种类
     */
    @PreAuthorize("@ss.hasPermi('simple:simpleType:edit')")
    @Log(title = "样品种类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SplSimpleType splSimpleType)
    {
        return toAjax(splSimpleTypeService.updateSplSimpleType(splSimpleType));
    }

    /**
     * 删除样品种类
     */
    @PreAuthorize("@ss.hasPermi('simple:simpleType:remove')")
    @Log(title = "样品种类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{simpleTypeIds}")
    public AjaxResult remove(@PathVariable Integer[] simpleTypeIds)
    {
        return toAjax(splSimpleTypeService.deleteSplSimpleTypeByIds(simpleTypeIds));
    }
}
